<?php


function GetTags($text){
	global $config;
	//stop list
$stoplist=file_get_contents($config["basefolder"]."/engine/".$config["modulefolder"]."/stopwords.txt");
$stoplist=explode("\r\n",$stoplist);
xAPLog("Tagging","Stoplist ".count($stoplist),"");



//first clean the text
$text=str_replace("&nbsp;"," ",$text);
$text=strip_tags($text);
$text=strtolower($text);
$text=preg_replace("/[^a-z0-9]/"," ",$text);

//array it
$base=explode(" ",$text);

foreach($base as $value){
	//clean whitepace
	$value=trim($value);
	// only 4 character words and nothing blanks
	if (strlen($value)>3 && $value!=""){
		// check the blacklist
		if(in_array($value,$stoplist)==false){
			//check the blacklist with out list character. ( crap way of checking plurals
			if(in_array(substr($value,0,strlen($value)-1),$stoplist)==false){
				//ignore anything with number
				$test=preg_replace("/[^0-9]/","",$value);
				if($test==""){
					//add 1 to the count and initialise if empty
					if (isset($tag[$value])==false){
						$tag[$value]=0;
					}
					$tag[$value]++;
					
				}
			}
		}
	}
}

arsort($tag);
xAPLog("Tagging","Found ".count($tag),"");
return $tag;
}
?>